// Context Menu
// This function working for right click
function searchOnClick(info, tab) {
	var searchText = JSON.stringify(info.selectionText);
	
	var createProperties = new Object();
    createProperties.url = "http://search.4shared.com/q/1/"+searchText.replace("\"", "").replace("\"", "")+"?view=ls";
	chrome.tabs.create(createProperties);
}

// Create item to selection event
var title = "Look up: \"%s\" with 4shared";
var id = chrome.contextMenus.create({"title": title, "contexts":["selection"],
                                   "onclick": searchOnClick});

// Ominibox
// This event is fired with the user accepts the input in the omnibox.
chrome.omnibox.onInputEntered.addListener(
  function(text) {
    var createProperties = new Object();
    createProperties.url = "http://search.4shared.com/q/1/"+text.replace("\"", "").replace("\"", "")+"?view=ls";
	chrome.tabs.create(createProperties);
  });